package org.teachertools.web;

import javax.servlet.ServletRequest;

import org.apache.struts.Globals;
import org.apache.struts.util.MessageResources;

/**
 * Classe contennant diverses fonctions simples : conversions, tests, ...
 * 
 * @author Dreamsoft
 * @version 1.0
 * @since 24 mai 2005
 */
public class I18nUtils {

    public static String getMessage(ServletRequest request, String key) {
        MessageResources messageResources = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY);
        if (messageResources != null) {
            return messageResources.getMessage(key);
        } else {
            return "???" + key + "???";
        }
    }

    public static String getMessage(ServletRequest request, String key, Object[] params) {
        MessageResources messageResources = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY);
        return messageResources.getMessage(key, params);
    }
}
